<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Insert title here</title>
    <script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
</head>
<body>
<h1>bingo security misroservice</h1>
<input type="button" value="获得订单信息" id="getOrderInfo"></input>
<input type="button" value="退出" id="logout"></input>
</body>
<script>
    authenication = false;
     var data = JSON.stringify({username : "tom",password : "123456"});
    $.ajax({
        url: "/login",
        type: "post",
        dataType: "json",
        data: data,
        headers: {'Content-Type': 'application/json'},
        success: function (res) {

        }
    })
    $("#getOrderInfo").click(function(){
        $.ajax({
            url: "/api/order/get/1",
            type: "get",
            success: function (res) {
                alert("获取成功！")
            }
        })

    })
    $("#logout").click(function(){
        $.ajax({
            url: "/logout",
            success: function (res) {
                window.location.href ='http://localhost:8083/logout?redirect_uri=http://localhost:8080';
            }
        })
    })

    $.ajax({
        url: "/me",
        /* dataType: "json",
        headers: {'Content-Type': 'application/json'}, */
        success: function (res) {
            console.log(res)
            if(res){
                console.log("已经通过认证")
                authenication = true;
            }

            if(!authenication){
                console.log(authenication)
                window.location.href = 'http://localhost:9090/oauth/authorize?client_id=admin&redirect_uri=http://localhost:8080/oauth/callback&'+'response_type=code&state=abc'
            }
        }
    })

    function tiaozhuan(){

    }
</script>
</html>